﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace xml_tu2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            /*
             * XmlDataDocument (namespace : System.Data)
             *  - allows structured data to be stored, retrieved, and manipulated thought
             *    a relational Dataset
             */
            XmlDataDocument xml_doc = new XmlDataDocument();
            /*
             * XmlNodeList (namespace: System.Xml)
             *  -- Represents an ordered collection of nodes.
             */ 
            XmlNodeList xml_node;
            int i = 0;
            System.String my_string = null;
            FileStream file_stream = new FileStream("product.xml", FileMode.Open, FileAccess.Read);
            xml_doc.Load(file_stream);
            xml_node = xml_doc.GetElementsByTagName("Product");
            for (i = 0; i <= xml_node.Count; i++)
            {
                xml_node[i].ChildNodes.Item(0).InnerText.Trim();
                my_string = xml_node[i].ChildNodes.Item(0).InnerText.Trim() + " | " + xml_node[i].ChildNodes.Item(1).InnerText.Trim() + " | " + xml_node[i].ChildNodes.Item(2).InnerText.Trim();
                MessageBox.Show(my_string);
            }
        }
    }
}
